Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eventemitter3

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventemitter3

EventEmitter3 focuses on performance while maintaining a Node.js AND browser compatible interface.

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40M
increased by3.6%
Maintainers
3
Weekly downloads
 
Created

What is eventemitter3?

The eventemitter3 package is a high-performance event emitter library that provides an interface for emitting and listening to events. It is a drop-in replacement for existing EventEmitter implementations with a focus on performance.

What are eventemitter3's main functionalities?

Emitting events

This feature allows you to emit events with a specified name and pass arguments to the event listeners.

const EventEmitter = require('eventemitter3');
const emitter = new EventEmitter();
emitter.on('greet', function(message) {
  console.log(message);
});
emitter.emit('greet', 'Hello World!');

Listening to events

This feature allows you to add a listener for a specific type of event. The listener will be invoked when an event with that name is emitted.

const EventEmitter = require('eventemitter3');
const emitter = new EventEmitter();
emitter.on('greet', function(message) {
  console.log(message);
});

Removing event listeners

This feature allows you to remove a specific listener from an event so that it no longer gets called when the event is emitted.

const EventEmitter = require('eventemitter3');
const emitter = new EventEmitter();
function onGreet(message) {
  console.log(message);
}
emitter.on('greet', onGreet);
emitter.removeListener('greet', onGreet);

Once listeners

This feature allows you to add a one-time listener for an event. The listener will be invoked only the first time the event is emitted, after which it is removed.

const EventEmitter = require('eventemitter3');
const emitter = new EventEmitter();
emitter.once('greet', function(message) {
  console.log('This will only be logged once:', message);
});
emitter.emit('greet', 'Hello World!');
emitter.emit('greet', 'Hello again!');

Other packages similar to eventemitter3

Keywords

FAQs

Package last updated on 16 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc